from odoo import api, fields, models


class RpCustomerInheritForMarketing(models.Model):
    _inherit = 'rp.customer'

    # 调价相关
    special_customer_tag = fields.Boolean(string='特殊客户标志', copy=False, index=True, default=False)

    # 优惠券相关
    rp_customer_coupon_ids = fields.One2many(string='客户关联优惠券', comodel_name='rp.customer.coupon', inverse_name='rp_customer_id', copy=False)
    remark = fields.Text(string='备注')

    # 邀请推广相关
    invite_code_ids = fields.One2many(string='邀请任务', comodel_name='rp.invite.schedule', inverse_name='rp_customer_id', copy=False)
    earn_invite_category = fields.Many2many(string='获得的邀请推广', comodel_name='rp.invite.category', column1='rp_customer_id',
                                            column2='invite__category_id', relation='rp_customer_invite_category_rel', copy=False)

    @api.onchange('special_customer_tag')
    def _onchange_for_customer(self):
        if self.special_customer_tag:
            self.update({'customer_level': False, 'customer_category': False})
